/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bugman.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Flashman
 */
@Entity
@Table(name = "CROLE")
@NamedQueries({
    @NamedQuery(name = "Role.findAll", query = "SELECT r FROM Role r"),
    @NamedQuery(name = "Role.findByShortName", query = "SELECT r FROM Role r WHERE r.shortName = :shortName")
})
        
public class Role implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final String findAll = "Role.findAll";
    public static final String findByShortName = "Role.findByShortName";

    public static final byte HOST = 1;
    public static final byte USER = 2;
    public static final byte DEVELOPER = 3;
    public static final byte ADMIN = 4;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Byte id;

    @Column(name = "name")
    private String name;

    @Column(name = "short")
    private Character shortName;
    
    @Column(name = "permision")
    private Short permision;

    public Role() {
    }

    public Role(Byte id) {
        this.id = id;
    }

    public Byte getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Character getShortName() {
        return shortName;
    }

    public void setShortName(Character shortName) {
        this.shortName = shortName;
    }

    public Short getPermision() {
        return permision;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Role)) {
            return false;
        }
        Role other = (Role) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return name + " (" + id + ")";
    }

}
